package com.qianbao.dao.order;


import com.qianbao.domain.order.OrderEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface OrderDao {


    /**
     * 查询用户的所有订单
     * @param customId
     * @return
     */
    @Select("select * from shop_order where custom_id = #{customId}")
    public List<OrderEntity> findAllOrderList(String customId);


    /**
     * 根据用户状态、查询用户的所有订单
     * @param orderState
     * @param customId
     * @return
     */
    @Select("select * from shop_order where custom_id = #{customId} and order_state = #{orderState}")
    public List<OrderEntity> findOrderWithOrderStateCustomId(@Param("customId")String customId,@Param("orderState")String orderState);


    /**
     * 插入一条订单信息
     * @param entity
     * @return
     */
    @Insert("insert into shop_order(order_id,order_state,address_id,name,phone,address,custom_id," +
            "goods_title,goods_pict_url,goods_reserve_price,goods_zk_final_price,goods_item_id," +
            "goods_nick,goods_shop_title,goods_coin_price) values(#{order_id},#{order_state},#{address_id}," +
            "#{name},#{phone},#{address},#{custom_id},#{goods_title},#{goods_pict_url},#{goods_reserve_price}," +
            "#{goods_zk_final_price},#{goods_item_id},#{goods_nick},#{goods_shop_title},#{goods_coin_price})")
    public int saveOrder(OrderEntity entity);


    /**
     * 更新用户的订单状态
     * @param orderId
     * @param state
     * @return
     */
    @Update("update shop_order set order_state = #{state} where order_id = #{orderId}")
    public int updateOrderState(@Param("orderId")String orderId,@Param("state")String state);



}

















